<?php

namespace App\Helpers\Formater;
use DateTime;

/**
 * 日期时间转换
 * @author qfh
 */
class DateTimeFormat
{

    /**
     * 计算两个时间的间隔
     * @param $from
     * @param $to
     * @return string
     */
    public static function diffDateTime($from,$to)
    {

        $diff = self::diffBetweenTwoDays($from, $to);
        return $diff;
    }

    static  function diffBetweenTwoDays ($day1, $day2)
    {
        $second1 = strtotime($day1);
        $second2 = strtotime($day2);

        if ($second1 < $second2) {
            $tmp = $second2;
            $second2 = $second1;
            $second1 = $tmp;
        }
        return ($second1 - $second2) / 86400;
    }



}
